package com.zhang.homework.search;

/**
 * @author zhang
 * @time 2022/02/21 09:39:52
 */

public class Test {
    public static int jumpSearch(int[] array, int target) {
        int blokcSize = (int) Math.sqrt(array.length);
        int start = 0;
        int next = start + blokcSize;
        while (array[next - 1] < target) {
            start = next;
            if (start > array.length) {
                break;
            }
            next += blokcSize;
            if (next > array.length) {
                next = array.length;
            }
        }
        for (int i = start; i < next; i++) {
            if (array[i] == target) {
                return i;
            }
        }
        return -1;
    }
    public static int exponentialSearch(int[] array, int target) {
        int bound = 1;
        while (array[bound] < target && bound < array.length) {
            bound *= 2;
        }
        int left = bound / 2;
        int right = Math.max(bound, array.length);
        //递归二分查找
        return -1;


    }
    public static void main(String[] args) {
        int[] array = {1, 3, 5, 6, 9, 1045, 67, 89, 100};
        System.out.println(jumpSearch(array, 5));
    }
}
